﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BestLifePOS_Core.Data.Fascade;

namespace BestLifePOS_PresentationLayer
{
    public partial class frmPooupbl : Form
    {
        DataTable GvPricelisttbl = new DataTable();
        DataTable GvUserDetailsGlobel = new DataTable();
        string Gvproductid = "";

        public frmPooupbl(string Pproductid)
        {
            InitializeComponent();
            Gvproductid = Pproductid;
        }

        private void frmPooupbl_Load(object sender, EventArgs e)
        {
            #region GVUserDetailsGlobel--Datatable

            GvUserDetailsGlobel.Columns.Add("Pro_ID");
            GvUserDetailsGlobel.Columns.Add("Pro_Name");
            GvUserDetailsGlobel.Columns.Add("Brand_Name");
            GvUserDetailsGlobel.Columns.Add("Pro_Price");
            GvUserDetailsGlobel.Columns.Add("Ret_Price");
            GvUserDetailsGlobel.Columns.Add("PV");
            GvUserDetailsGlobel.Columns.Add("BV");
            GvUserDetailsGlobel.Columns.Add("Quantity");


            #endregion
            GridFill();
        }

        #region GridFill
        public void GridFill()
        {

            if (Gvproductid.Length == 7)
            {
                GvPricelisttbl = ProductDAO.GetProductByIdForPos(Gvproductid, "0");
                for (int i = 0; i <= GvPricelisttbl.Rows.Count - 1; i++)
                {
                    GvUserDetailsGlobel.Rows.Add(GvUserDetailsGlobel.NewRow());
                    GvUserDetailsGlobel.Rows[GvUserDetailsGlobel.Rows.Count - 1][0] = GvPricelisttbl.Rows[i][0].ToString();
                    GvUserDetailsGlobel.Rows[GvUserDetailsGlobel.Rows.Count - 1][1] = GvPricelisttbl.Rows[i][1].ToString();
                    GvUserDetailsGlobel.Rows[GvUserDetailsGlobel.Rows.Count - 1][2] = GvPricelisttbl.Rows[i][2].ToString();
                    GvUserDetailsGlobel.Rows[GvUserDetailsGlobel.Rows.Count - 1][3] = GvPricelisttbl.Rows[i][3].ToString();
                    GvUserDetailsGlobel.Rows[GvUserDetailsGlobel.Rows.Count - 1][4] = GvPricelisttbl.Rows[i][4].ToString();
                    GvUserDetailsGlobel.Rows[GvUserDetailsGlobel.Rows.Count - 1][5] = GvPricelisttbl.Rows[i][5].ToString();
                    GvUserDetailsGlobel.Rows[GvUserDetailsGlobel.Rows.Count - 1][6] = GvPricelisttbl.Rows[i][6].ToString();
                    GvUserDetailsGlobel.Rows[GvUserDetailsGlobel.Rows.Count - 1][7] = GvPricelisttbl.Rows[i][7].ToString();
                }

                dgvpoppricelist.DataSource = GvUserDetailsGlobel;
            }
            else
            {

            }

        }
        #endregion

        private void dgvpoppricelist_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {

                if (MessageBox.Show("Will you really Add the item?", "Warning", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    MessageBox.Show("Show" + e.KeyChar + "" + dgvpoppricelist.Rows[dgvpoppricelist.CurrentRow.Index - 1].Cells[0].Value.ToString());
                    //Call some methods to delete the item you want to remove.
                }
                else { MessageBox.Show("Nooooooo :)" + e.KeyChar + "" + dgvpoppricelist.Rows[dgvpoppricelist.CurrentRow.Index - 1].Cells[0].Value.ToString()); }
            }
            else
            {
                MessageBox.Show(":P" + e.KeyChar + "");
            }
           
        }

    }
}
